//package edu.hubu;
//
//import edu.hubu.dao.impl.IInstitutionDao;
//import edu.hubu.dao.impl.IStudentDao;
//import edu.hubu.dao.impl.ITeacherDao;
//import edu.hubu.dao.impl.IUserDao;
//import edu.hubu.model.*;
//import edu.hubu.service.impl.*;
//import org.junit.jupiter.api.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.test.annotation.Rollback;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author moonlan
// * date 2020/11/13 20:02
// */
//@SuppressWarnings(value = "unused")
//@SpringBootTest
//public class CreateTable {
//    @Autowired
//    AnnouncementService announcementService;
//
//    @Autowired
//    AnnouncementTypeService announcementTypeService;
//
//    @Autowired
//    BookService bookService;
//
//    @Autowired
//    CourseHourService courseHourService;
//
//    @Autowired
//    CourseService courseService;
//
//    @Autowired
//    CourseTypeService courseTypeService;
//
//    @Autowired
//    CreditService creditService;
//
//    @Autowired
//    InstitutionService institutionService;
//
//    @Autowired
//    MajorService majorService;
//
//    @Autowired
//    PermissionService permissionService;
//
//    @Autowired
//    RoleService roleService;
//
//    @Autowired
//    StudentCourseService studentCourseService;
//
//    @Autowired
//    StudentService studentService;
//
//    @Autowired
//    TeacherService teacherService;
//
//    @Autowired
//    TeacherCourseService teacherCourseService;
//
//    @Autowired
//    TermService termService;
//
//    @Autowired
//    TokenService tokenService;
//
//    @Autowired
//    UserClassService userClassService;
//
//    @Autowired
//    UserService userService;
//
//    @Autowired
//    IUserDao userDao;
//
//    @Autowired
//    IStudentDao studentDao;
//
//    @Autowired
//    ITeacherDao teacherDao;
//
//    @Autowired
//    BCryptPasswordEncoder encoder;
//
//    @Autowired
//    IInstitutionDao iInstitutionDao;
//    @Test
//    void createTable() {
//
//    }
//
//    @Test
//    @Transactional
//    @Rollback(value = false)
//    void addData() {
//        /*//User
//        for (int i = 0; i < 3; i++) {
//            userService.add(User.builder().userName("syy" + i).userPassword(encoder.encode("123")).userTelephoneNumber("1234567890").build());
//        }
//        //--------------------------------------
//        //AnnouncementType
//        for (int i = 0; i < 3; i++) {
//            announcementTypeService.add(AnnouncementType.builder().announcementTyeName("公告" + i).build());
//        }
//        //--------------------------------------
//        //Announcement
//        List<User> all = userDao.findAll();
//        List<AnnouncementType> announcementTypeList = Object2List.toList(announcementTypeService.findAllPage(0, 5).getData(), AnnouncementType.class);
//        for (int i = 0; i < 3; i++) {
//            switch (i) {
//                case 0:
//                    announcementService.add(Announcement.builder().announcementBrief("公告简介").announcementContent("湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻").announcementTitle("湖北大学今日要闻").user(all.get(i)).announcementType(announcementTypeList.get(i)).build());
//                case 1:
//                    announcementService.add(Announcement.builder().announcementBrief("公告简介").announcementContent("湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻").announcementTitle("湖北大学今日要闻").user(all.get(i)).announcementType(announcementTypeList.get(i)).build());
//                case 2:
//                    announcementService.add(Announcement.builder().announcementBrief("公告简介").announcementContent("湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻湖北大学今日要闻").announcementTitle("湖北大学今日要闻").user(all.get(i)).announcementType(announcementTypeList.get(i)).build());
//            }
//        }
//        //--------------------------------------
//        //Book
//        Book 计算机网络 = Book.builder().bookDescription("计算机网络（英语：computer network），通常也简称网络，是指容许节点分享资源的数字电信网络[1]:1-3。在电脑网络，电脑设备会透过节点之间的连接（数据链路）互相交换数据。传输介质可分为有线及无线两类——有线的可用到双绞线、光纤电缆等介质[1]:1-4；无线则可用到Wi-Fi、NFC[2]:4-32。").bookName("计算机网络").bookPrice(30).build();
//        bookService.add(计算机网络);
//        Book 计算机组成原理 = Book.builder().bookName("计算机组成原理").bookDescription("“计算机组成原理”是入门和底层层面的第一课").bookPrice(30).build();
//        bookService.add(计算机组成原理);
//        Book 操作系统 = Book.builder().bookDescription("").bookName("操作系统").bookPrice(30).build();
//        bookService.add(操作系统);
//        Book 算法设计 = Book.builder().bookName("算法设计").bookPrice(30).build();
//        bookService.add(算法设计);
//        //--------------------------------------
//        //Institution
//
//        //--------------------------------------
//        //Major
//        List<Institution> institutionList = Object2List.toList(institutionService.findAllPage(0, 5).getData(), Institution.class);
//
//        //--------------------------------------
//        //Teacher
//        List<Major> majorList = Object2List.toList(majorService.findAllPage(0, 5).getData(), Major.class);
//        for (int i = 0; i < 2; i++) {
//            Teacher teacher = new Teacher();
//            teacher.setUserName("syy" + i);
//            teacher.setUserPassword("123");
//            teacher.setInstitution(institutionList.get(i));
//            teacher.setMajor(majorList.get(i));
//            teacherService.add(teacher);
//        }
//        //--------------------------------------
//        List<Teacher> teacherList = teacherDao.findAll();
//
//        for (int i = 0; i < teacherList.size(); i++) {
//            userClassService.add(UserClass.builder().userClassNumber(20L).userClassName("班级" + i).major(majorList.get(0)).build());
//        }
//
//        ResultsJson page = userClassService.findAllPage(0, 20);
//        List<UserClass> data = Object2List.toList(page.getData(), UserClass.class);
//        int count = 10;
//        for (int i = 0; i < 5; i++) {
//            for (int j = 0; j < 3; j++) {
//                Student student = new Student();
//                student.setUserName("wl" + j);
//                student.setUserPassword("123");
//                student.setInstitution(institutionList.get(i));
//                student.setMajor(majorList.get(j));
//                student.setStudentClass(data.get(0));
//                studentService.add(student);
//            }
//        }
//
//        courseTypeService.add(CourseType.builder().courseTypeName("必修课").build());
//        courseTypeService.add(CourseType.builder().courseTypeName("选修课").build());
//        courseTypeService.add(CourseType.builder().courseTypeName("公选课").build());
//        courseTypeService.add(CourseType.builder().courseTypeName("专选课").build());
//        //
//        List<Book> bookList = Object2List.toList(bookService.findAllPage(0, 5).getData(), Book.class);
//        List<Major> majors = Object2List.toList(majorService.findAllPage(0, 5).getData(), Major.class);
//        List<CourseType> courseTypes = Object2List.toList(courseTypeService.findAllPage(0, 5).getData(), CourseType.class);
//        for (int i = 0; i < bookList.size(); i++) {
//            switch (i) {
//                case 0:
//                    courseService.add(Course.builder().courseName("计算机网络").build());
//                case 1:
//                    courseService.add(Course.builder().courseName("计算机组成原理").build());
//                case 2:
//                    courseService.add(Course.builder().courseName("操作系统").build());
//                case 3:
//                    courseService.add(Course.builder().courseName("算法设计").build());
//            }
//        }
//
//        courseHourService.add(CourseHour.builder().courseHour(48).build());
//        courseHourService.add(CourseHour.builder().courseHour(64).build());
//        courseHourService.add(CourseHour.builder().courseHour(36).build());
//        courseHourService.add(CourseHour.builder().courseHour(72).build());
//
//        creditService.add(Credit.builder().credit((double) 5).build());
//        creditService.add(Credit.builder().credit((double) 3).build());
//        creditService.add(Credit.builder().credit((double) 2).build());
//        creditService.add(Credit.builder().credit((double) 1).build());
//
//        TeacherCourse teacherCourse = new TeacherCourse();
//        List<Course> courseList = Object2List.toList(courseService.findAllPage(0, 5).getData(), Course.class);
//        List<CourseHour> courseHours = Object2List.toList(courseHourService.findAllPage(0, 5).getData(), CourseHour.class);
//        List<Credit> credits = Object2List.toList(creditService.findAllPage(0, 5).getData(), Credit.class);
//        for (int i = 0; i < teacherList.size(); i++) {
//            teacherCourse.setCourse(courseList.get(i));
//            teacherCourse.setBook(bookList.get(i));
//            teacherCourse.setCourseHour(courseHours.get(i));
//            teacherCourse.setCourseType(courseTypes.get(i));
//            teacherCourse.setCredit(credits.get(i));
//            teacherCourse.setTeacherCourseMaxNums(20);
//            teacherCourse.getTeachers().add(teacherList.get(i));
//            teacherCourseService.add(teacherCourse);
//        }*/
//
//        Permission updateUser = Permission.builder().permissionName("updateUser").build();
//        Permission forbiddenUser = Permission.builder().permissionName("forbiddenUser").build();
//        Permission deleteUser = Permission.builder().permissionName("deleteUser").build();
//        Permission findUser = Permission.builder().permissionName("findUser").build();
//        Permission countUser = Permission.builder().permissionName("countUser").build();
//        permissionService.add(updateUser);
//        permissionService.add(forbiddenUser);
//        permissionService.add(deleteUser);
//        permissionService.add(findUser);
//        permissionService.add(countUser);
//
//        Permission updateStudent = Permission.builder().permissionName("updateStudent").build();
//        Permission forbiddenStudent = Permission.builder().permissionName("forbiddenStudent").build();
//        Permission deleteStudent = Permission.builder().permissionName("deleteStudent").build();
//        Permission findStudent = Permission.builder().permissionName("findStudent").build();
//        Permission countStudent = Permission.builder().permissionName("countStudent").build();
//        permissionService.add(updateStudent);
//        permissionService.add(forbiddenStudent);
//        permissionService.add(deleteStudent);
//        permissionService.add(findStudent);
//        permissionService.add(countStudent);
//
//        Permission updateTeacher = Permission.builder().permissionName("updateTeacher").build();
//        Permission forbiddenTeacher = Permission.builder().permissionName("forbiddenTeacher").build();
//        Permission deleteTeacher = Permission.builder().permissionName("deleteTeacher").build();
//        Permission findTeacher = Permission.builder().permissionName("findTeacher").build();
//        Permission countTeacher = Permission.builder().permissionName("countTeacher").build();
//        permissionService.add(updateTeacher);
//        permissionService.add(forbiddenTeacher);
//        permissionService.add(deleteTeacher);
//        permissionService.add(findTeacher);
//        permissionService.add(countTeacher);
//
//        Permission update = Permission.builder().permissionName("update").build();
//        Permission forbidden = Permission.builder().permissionName("forbidden").build();
//        Permission delete = Permission.builder().permissionName("delete").build();
//        Permission find = Permission.builder().permissionName("find").build();
//        Permission count = Permission.builder().permissionName("count").build();
//        permissionService.add(update);
//        permissionService.add(forbidden);
//        permissionService.add(delete);
//        permissionService.add(find);
//        permissionService.add(count);
//
//
//        Role student = new Role();
//        student.setRoleName("student");
//        student.getPermissions().add(updateStudent);
//        student.getPermissions().add(forbiddenStudent);
//        student.getPermissions().add(deleteStudent);
//        student.getPermissions().add(findStudent);
//        student.getPermissions().add(countStudent);
//        roleService.add(student);
//        Role teacher = new Role();
//        teacher.setRoleName("teacher");
//        teacher.getPermissions().add(updateTeacher);
//        teacher.getPermissions().add(forbiddenTeacher);
//        teacher.getPermissions().add(deleteTeacher);
//        teacher.getPermissions().add(findTeacher);
//        teacher.getPermissions().add(countTeacher);
//        roleService.add(teacher);
//        Role worker = new Role();
//        worker.setRoleName("worker");
//        worker.getPermissions().add(updateUser);
//        worker.getPermissions().add(forbiddenUser);
//        worker.getPermissions().add(deleteUser);
//        worker.getPermissions().add(findUser);
//        worker.getPermissions().add(countUser);
//        roleService.add(worker);
//        Role admin = new Role();
//        admin.setRoleName("admin");
//        admin.getPermissions().add(update);
//        admin.getPermissions().add(forbidden);
//        admin.getPermissions().add(delete);
//        admin.getPermissions().add(find);
//        admin.getPermissions().add(count);
//        roleService.add(admin);
//
//        ArrayList<Role> students = new ArrayList<>();
//        students.add(student);
//        ArrayList<Role> teachers = new ArrayList<>();
//        teachers.add(teacher);
//        ArrayList<Role> workers = new ArrayList<>();
//        workers.add(worker);
//        ArrayList<Role> admins = new ArrayList<>();
//        admins.add(admin);
//
//        Student syy = new Student();
//        syy.setUserName("烨磊");
//        syy.setUserPassword(encoder.encode("123"));
//        syy.setUserSid("USER-2020-11111111");
//        syy.setUserTelephoneNumber("123456789012");
//        syy.setRoles(students);
//        syy.setInstitution(institutionService.findById("INSTITUTION-2020-36520478"));
//        syy.setMajor(majorService.findById("MAJOR-2020-29273112"));
//        studentService.addEntity(syy);
//        Teacher xyf = new Teacher();
//        xyf.setUserName("远航");
//        xyf.setUserPassword(encoder.encode("123"));
//        xyf.setUserSid("USER-2020-11111112");
//        xyf.setUserTelephoneNumber("123456789012");
//        xyf.setRoles(teachers);
//        xyf.setInstitution(institutionService.findById("INSTITUTION-2020-36520478"));
//        xyf.setMajor(majorService.findById("MAJOR-2020-29273112"));
//        teacherService.add(xyf);
//        User fyw = User.builder().userName("凯瑞").userPassword(encoder.encode("123")).userSid("USER-2020-11111113").userTelephoneNumber("123456789012").userPhotoUrl("http://192.168.31.154:40000/img/3.jpg").roles(admins).build();
//        userService.addEntity(fyw);
//        Student csy = new Student();
//        csy.setUserName("睿渊");
//        csy.setUserPassword(encoder.encode("123"));
//        csy.setUserSid("USER-2020-11111114");
//        csy.setUserTelephoneNumber("123456789012");
//        csy.setRoles(students);
//        csy.setInstitution(institutionService.findById("INSTITUTION-2020-42744954"));
//        csy.setMajor(majorService.findById("MAJOR-2020-73785939"));
//        studentService.addEntity((Student) csy);
//        User rsl = User.builder().userName("健雄").userPassword(encoder.encode("123")).userSid("USER-2020-11111115").userTelephoneNumber("123456789012").userPhotoUrl("http://192.168.31.154:40000/img/5.jpg").roles(workers).build();
//        userService.addEntity(rsl);
//        Student hjy = new Student();
//        hjy.setUserName("熙栋");
//        hjy.setUserPassword(encoder.encode("123"));
//        hjy.setUserSid("USER-2020-11111116");
//        hjy.setUserTelephoneNumber("123456789012");
//        hjy.setRoles(students);
//        hjy.setInstitution(institutionService.findById("INSTITUTION-2020-83030669"));
//        hjy.setMajor(majorService.findById("MAJOR-2020-90479103"));
//        studentService.addEntity((Student) hjy);
//
//
//    }
//    @Test
//    @Transactional
//    @Rollback(value = false)
//    void addCourseHour() {
////        for (int i = 0; i < 5; i++) {
////            CourseHour courseHour = new CourseHour();
////            courseHour.setCourseHour(64);
////            courseHourService.add(courseHour);
////        }
////        for (int i = 0; i < 4; i++) {
////            CourseType courseType = new CourseType();
////            courseType.setCourseTypeName("必修课");
////            courseTypeService.add(courseType);
////        }
////        for (int i = 0; i < 4; i++) {
////            Credit credit = new Credit();
////            credit.setCredit(3.0);
////            creditService.add(credit);
////        }
//        TeacherCourse teacherCourse1 = new TeacherCourse();
//        teacherCourse1.setCourse(courseService.findById("COURSE-2020-42617830"));
//        teacherCourse1.setCourseHour(courseHourService.findById("COURSE-HOUR-2020-11111111"));
//        teacherCourse1.setCourseType(courseTypeService.findById("COURSE-TYPE-2020-11111111"));
//        teacherCourse1.setCredit(creditService.findById("CREDIT-2020-11111111"));
//        teacherCourseService.add(teacherCourse1);
//
//        TeacherCourse teacherCourse2 = new TeacherCourse();
//        teacherCourse1.setCourse(courseService.findById("COURSE-2020-60455845"));
//        teacherCourse1.setCourseHour(courseHourService.findById("COURSE-HOUR-2020-11111112"));
//        teacherCourse1.setCourseType(courseTypeService.findById("COURSE-TYPE-2020-11111112"));
//        teacherCourse1.setCredit(creditService.findById("CREDIT-2020-11111112"));
//        teacherCourseService.add(teacherCourse2);
//
//        TeacherCourse teacherCourse3 = new TeacherCourse();
//        teacherCourse1.setCourse(courseService.findById("COURSE-2020-74137388"));
//        teacherCourse1.setCourseHour(courseHourService.findById("COURSE-HOUR-2020-11111113"));
//        teacherCourse1.setCourseType(courseTypeService.findById("COURSE-TYPE-2020-11111113"));
//        teacherCourse1.setCredit(creditService.findById("CREDIT-2020-11111113"));
//        teacherCourseService.add(teacherCourse3);
//    }
//}
